/**
 * Created by chesw on 2017/5/18.
 */
(function () {
    new Vue({
        el: '#medicine-wiki',
        components: {
            'clinic-head': clinicHead,
            'clinic-right': clinicRight,
            'clinic-foot': clinicFoot,
            'clinic-page': clinicPage,
            'search': search,
            'say-sick': saySick,
            'graphic-list-frame': graphicListFrame,
            'graphic-frame': graphicFrame,
            'guide-consensus': guideConsensus
        },
        data: {
            graphicInfo: {
                type: true, //标题显示
                showTitle: true,
                showShare: false, //是否显示分享按钮
                showPic: false,
                showList: true,
                showNavBar: true,
                showRelevant: false,
                style: { width: '1190px', margin: '0px' }, //组件宽度
                detailStyle: { height: '200px' },
                class: "graphic-list-detail flex"
            },
            tab_id: 1, //1:专家说病; 2:疾病大全; 3:病案分享; 4:指南共识
            userName: '',
            loginInfo: { isLogin: '', name: '', mobile: '' },
            showPageParam: {},
            searchParam:{},
            detailInfo: {},
            navigationBar: {}
        },
        mounted: function () {
            var _self = this;
            showHtml();
            //设置导航栏样式
            document.getElementById("Home").className = "invalid-nav";
            document.getElementById("OrderExpert").className = "invalid-nav";
            document.getElementById("DistinctMedical").className = "invalid-nav";
            document.getElementById("MedicalWiki").className = "valid-nav";
            document.getElementById("News").className = "invalid-nav";
            document.getElementById("AboutUs").className = "invalid-nav";

            var p_id = getQueryString("Id");

            if (p_id != null) {
                _self.getArticleDetial(p_id);             
            }
            else {
                var TabId = getQueryString("TabId");
                if (TabId != null) {
                    _self.tab_id = TabId;
                    _self.changeTab(_self.tab_id);
                }
                else {
                    _self.tab_id = 1;
                    _self.changeTab(_self.tab_id);
                }
            }                                
        },
        created: function () {
            var _self = this;          
            //检查登录状态
            CheckLoginStatus(_self, _self.loginInfo);                        
        },
        methods: {
            changeTab: function (p_type) {
                var _self = this;
                _self.tab_id = p_type;
                if (p_type === 1 || p_type === "1"){
                    //_self.$refs.saySick.GeSaySickCategories();
                    _self.$refs.saySick.GetSaySickDocumentList("");
                }                   
                else if (p_type === 2 || p_type === "2") {
                    //_self.$refs.diseaseWiki.GetDiseaseWikiCategories();
                    _self.$refs.diseaseWiki.GetDiseaseWikiDocumentList("");
                }
                else if (p_type === 3 || p_type === "3") {
                    //_self.$refs.sharingCase.GeSharingCaseCategories();
                    _self.$refs.sharingCase.GetSharingCaseDocumentList("");
                }
                else if (p_type === 4 || p_type === "4") {
                    _self.$refs.guideConsensus.GetCategories();
                    _self.$refs.guideConsensus.GetGuideConsensusDocuments("");
                }
            },
            showPage: function (p_param) {
                var _self = this;
                _self.showPageParam = p_param;
            },
            searchArticle: function (p_key) {
                var _self = this;
                if (_self.tab_id === 1 || _self.tab_id === "1"){
                    //_self.$refs.saySick.GeSaySickCategories();
                    _self.$refs.saySick.GetSaySickDocumentList(p_key);
                }                   
                else if (_self.tab_id === 2 || _self.tab_id === "2") {
                    //_self.$refs.diseaseWiki.GetDiseaseWikiCategories();
                    _self.$refs.diseaseWiki.GetDiseaseWikiDocumentList(p_key);
                }
                else if (_self.tab_id === 3 || _self.tab_id === "3") {
                    //_self.$refs.sharingCase.GeSharingCaseCategories();
                    _self.$refs.sharingCase.GetSharingCaseDocumentList(p_key);
                }
                else if (_self.tab_id === 4 || _self.tab_id === "4") {
                    _self.$refs.guideConsensus.GetCategories();
                    _self.$refs.guideConsensus.GetGuideConsensusDocuments(p_key);
                }
            },
            getArticleDetial: function (p_id) {
                var _self = this;
                _self.$refs.diseaseWiki.GetArticleDetial(p_id);
            },
            showDetail: function (p_val, p_param) {
                var _self = this;
                _self.getCurTabNavBar();
                _self.tab_id= p_val;
                _self.detailInfo = p_param;
                
            },
            getCurTabNavBar: function ()
            {
                var _self = this;
                if (_self.tab_id === 1 || _self.tab_id === "1")
                    _self.navigationBar = [{ name: '医学百科', url: '/MedicalWiki/Index' }, { name: '专家说病', url: '/MedicalWiki/Index?tabId=1' }];
                else if (_self.tab_id === 2 || _self.tab_id === "2")
                    _self.navigationBar = [{ name: '医学百科', url: '/MedicalWiki/Index' }, { name: '疾病大全', url: '/MedicalWiki/Index?tabId=2' }];
                else if (_self.tab_id === 3 || _self.tab_id === "3")
                    _self.navigationBar = [{ name: '医学百科', url: '/MedicalWiki/Index' }, { name: '病案分享', url: '/MedicalWiki/Index?tabId=3' }];
            }
        }
    })
})();
